home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-19 | 4.1 KB | 140 lines | [TEXT/MPS ] |
- **
- ** Apple Macintosh Developer Technical Support
- **
- ** Driver.a: MPW DRVR header and glue for RamDisk
- **
- ** by Gordon Sheridan and Jim Luther
- ** modified by Brian Bechtel
- **
- ** File: RamCDev.c
- **
- ** Copyright © 1992-1994 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DTS Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes.
- **
- ** Change History (most recent first):
- **
- ** Change History (most recent first):
- **
- ** <1> 10/94 BL°B Corrected asynch not-complete return case
- ** to put 0 in D0.
- ** <0> 10/93 gs and JML Clean up for Sample Code release.
- **
-
- STRING PASCAL
- CASE ON
-
- MAIN
-
- IMPORT DRVROPEN
- IMPORT DRVRPRIME
- IMPORT DRVRCONTROL
- IMPORT DRVRSTATUS
- IMPORT DRVRCLOSE
-
- INCLUDE 'SysEqu.a'
-
-
- DHeader
-
- DFlags DC.B 0 ; set by DRVROpen
- DC.B 0 ; set by DRVROpen
- DDelay DC.W 0 ; none
- DEMask DC.W 0 ; da event mask
- DMenu DC.W 0 ; no menu
-
- DC.W DOpen - DHeader ; offset to Open
- DC.W DPrime - DHeader ; offset to Prime
- DC.W DControl - DHeader ; offset to Control
- DC.W DStatus - DHeader ; offset to Status
- DC.W DClose - DHeader ; offset to Close
-
- Name DC.B '.RamDRVR' ; name of driver
- ALIGN 2 ; word align
-
- DOpen pea DRVROPEN
- bra.s DRVRDispatch
-
- DPrime pea DRVRPRIME
- bra.s DRVRDispatch
-
- DControl pea DRVRCONTROL
- bra.s DRVRDispatch
-
- DStatus pea DRVRSTATUS
- bra.s DRVRDispatch
-
- DClose pea DRVRCLOSE ; and fall thru to DRVRDispatch
-
- DRVRDispatch
- movem.l a0/a1, -(sp) ; save registers (for IODone)
-
- ; call driver routines with Pascal calling conventions
- clr.w -(sp) ; save room for result
- move.l a0, -(sp) ; push paramblock ptr on stack
- move.l a1, -(sp) ; push dce ptr on stack
- movea.l $12(sp), a0 ; load address of driver routine into a0
- jsr (a0) ; go to it!
-
- move.w (sp)+, d0 ; put result into d0
- movem.l (sp)+, a0/a1 ; restore registers (for IODone)
- addq.w #4, a7 ; clear driver routine address off stack
-
- ; Check for special case exits (Open, Close, KillIO, Immediate, incomplete Async)
- ; Open, Close and KillIO always RTS to the Device Manager with the driver result
- ; in
-
- move.w ioTrap(a0), d1 ; copy low byte of trap word to d1
-
- ; _Open check
- tst.b d1 ; _Open == A000
- beq.s Done ; rts if _Open
-
- ; _Close check
- cmpi.b #1, d1 ; _Close == A001
- beq.s Done ; rts if _Close
-
- ; _KillIO check
- cmpi.b #6, d1 ; _KillIO == A006
- beq.s Done ; rts if _KillIO
-
- ; It must be _Read, _Write, _Control, or _Status
-
- ; Immediate check
- btst #noQueueBit, d1 ; test immediate bit
- beq.s NotImmediate ; branch if not immediate
- move.w d0, ioResult(a0) ; The Device Manager doesn't set ioResult,
- ; so we do just in case the caller checks
- ; ioResult instead of the function result.
- bra.s Done ; rts if immediate
-
- NotImmediate
-
- ; 941027 BL°B
- ; If the call is asynchronous and not complete, it should return noErr (0)
- ; in D0 instead of 1 -- otherwise, the Device Manager sees the 1 and
- ; returns 1 as an error to the caller. If the File Manager is the caller,
- ; it converts the 1 to ioErr and returns it to the program that called
- ; it. See develop issue 13 page 10.
- ;
- ; Incomplete Async check
- cmp.w #1, d0 ; We're using the convention that if the
- ; driver result = 1 then the device driver
- ; hasn't completed the non-immediate
- ; operation.
- bne.s Complete
- moveq #0, d0 ; clear D0 and...
- bra.s Done ; rts if the operation is incomplete
-
- Complete move.l JIODone, -(sp) ; push jIODone onto stack
- Done rts
-
- END
-